<!doctype html>
<html>

<head>
  <!-- css文件 -->
  {include file="public/title" /}
</head>
<body data-type="generalComponents">
  <!-- 头部 -->
  {include file="public/header" /}
  <div class="tpl-page-container tpl-page-header-fixed">
    <!-- 左侧导航 -->
    {include file="public/leftNav" /}
    <div class="tpl-content-wrapper">
      <ol class="am-breadcrumb">
        <li><a href="#" class="am-icon-home">首页</a></li>
        <li><a href="#">文章管理</a></li>
        <li class="am-active">文章列表</li>
      </ol>
      <div class="tpl-portlet-components">
        <div class="tpl-block">
          <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
              <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                  <button type="button" class="am-btn am-btn-default am-btn-success">
                    <a href="{:url('article/add')}" style="color:#fff;">
                      <span class="am-icon-plus"></span>新增
                    </a>
                  </button>
                  <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span>
                    批量删除</button>
                </div>
              </div>
            </div>
            <div class="am-u-sm-12 am-u-md-3">
              <div class="am-form-group">
                <select data-am-selected="{btnSize: 'sm'}">
                  <option value="option1">所有类别</option>
                  <option value="option2">超级管理员</option>
                  <option value="option3">普通管理员</option>
                </select>
              </div>
            </div>
            <div class="am-u-sm-12 am-u-md-3">
              <div class="am-input-group am-input-group-sm">
                <input type="text" class="am-form-field">
                <span class="am-input-group-btn">
                  <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search" type="button"></button>
                </span>
              </div>
            </div>
          </div>
          <div class="am-g">
            <div class="am-u-sm-12">
              <table class="am-table am-table-striped am-table-hover table-main">
                <thead>
                  <tr>
                    <th class="table-check" width="5%"><input type="checkbox" class="tpl-table-fz-check"></th>
                    <th class="table-id" width="5%">ID</th>
                    <th class="table-title" width="10%">文章缩略图</th>
                    <th class="table-set" width="10%">标题</th>
                    <th class="table-set" width="15%">描述</th>
                    <th class="table-set" width="10%">作者</th>
                    <th class="table-set" width="10%">所属栏目</th>
                    <th class="table-set" width="10%">发布时间</th>
                    <th class="table-set" width="25%">操作</th>
                  </tr>
                </thead>
                <tbody>
                  {volist name="article" id="vo"}
                  <tr>
                    <td><input type="checkbox"></td>
                    <td>{$vo.id}</td>
                    <td><a href="#">
                      {if condition="$vo['pic'] neq ''"}
                      <img src="{$vo.pic}" width="100%" alt="">
                      {else /}
                      暂无缩略图
                      {/if}
                    </a></td>
                    <td><a href="#"><?php echo mb_substr($vo['title'],0,26); if(mb_strlen($vo['title'])>26){echo '...';};?></a></td>
                    <td><a href="#"><?php echo mb_substr($vo['desc'],0,44); if(mb_strlen($vo['desc'])>44){echo '...';};?></a></td>
                    <td>{$vo.author}</td>
                    <td>{$vo.catename}</td>
                    <td>{$vo.create_time}</td>
                    <td>
                      <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <a href="{:url('edit',['id'=>$vo.id])}"><button class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span>
                            编辑</button></a>
                            <a href="javascript:void(0)" onclick="del(this,{$vo.id})"><button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><span class="am-icon-trash-o"></span>
                            删除</button></a>
                        </div>
                      </div>
                    </td>
                  </tr>
                  {/volist}
                </tbody>
              </table>
              
              <div class="am-cf">
                <div class="am-fr">
                  <!-- 分页 -->
                  {$article->render()}
                </div>
              </div>

              <hr>
            </div>
          </div>
        </div>
        <div class="tpl-alert"></div>
      </div>
    </div>
  </div>
  <!-- js -->
  {include file="public/foot" /}
  <script>
    function del(obj,id){
      $.post("{:url('article/del')}",{id:id},function(data){
        if(data.code==1){
          layer.alert(data.msg, {icon: 6});
          $(obj).parent().parent().parent().parent().remove();
        }else{
          layer.alert(data.msg, {icon: 5});
        }
      })
    }
  </script>
</body>

</html>